package com.yida.wy.common.excel.convert;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.ReadConverterContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.Cell;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.Table;
import com.yida.common.core.text.Convert;
import com.yida.common.core.utils.StringUtils;
import com.yida.wy.common.excel.config.ConverConfig;

import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * @author hmh
 * @date 2023/11/22
 */
@Slf4j
public class ExcelAreaConvert implements Converter<Object> {

    private static final String AREA =
        "[{\"areaId\":1,\"areaName\":\"泉州市\",\"areaType\":1,\"parentId\":0,\"status\":\"0\"},{\"areaId\":2,\"areaName\":\"鲤城区\",\"areaType\":2,\"parentId\":1,\"status\":\"0\"},{\"areaId\":14,\"areaName\":\"海滨街道\",\"areaType\":3,\"parentId\":2,\"status\":\"0\"},{\"areaId\":22,\"areaName\":\"东湖街道\",\"areaType\":3,\"parentId\":3,\"status\":\"0\"},{\"areaId\":30,\"areaName\":\"万安街道\",\"areaType\":3,\"parentId\":4,\"status\":\"0\"},{\"areaId\":36,\"areaName\":\"山腰街道\",\"areaType\":3,\"parentId\":5,\"status\":\"0\"},{\"areaId\":43,\"areaName\":\"湖滨街道\",\"areaType\":3,\"parentId\":6,\"status\":\"0\"},{\"areaId\":52,\"areaName\":\"青阳街道\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":61,\"areaName\":\"溪美街道\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":87,\"areaName\":\"螺城镇\",\"areaType\":3,\"parentId\":9,\"status\":\"0\"},{\"areaId\":102,\"areaName\":\"凤城镇\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":126,\"areaName\":\"桃城镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":148,\"areaName\":\"浔中镇\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":170,\"areaName\":\"清濛经济技术开发区\",\"areaType\":3,\"parentId\":169,\"status\":\"0\"},{\"areaId\":185,\"areaName\":\"烈屿乡\",\"areaType\":3,\"parentId\":13,\"status\":\"0\"},{\"areaId\":191,\"areaName\":\"百崎乡\",\"areaType\":3,\"parentId\":168,\"status\":\"0\"},{\"areaId\":3,\"areaName\":\"丰泽区\",\"areaType\":2,\"parentId\":1,\"status\":\"0\"},{\"areaId\":15,\"areaName\":\"临江街道\",\"areaType\":3,\"parentId\":2,\"status\":\"0\"},{\"areaId\":23,\"areaName\":\"丰泽街道\",\"areaType\":3,\"parentId\":3,\"status\":\"0\"},{\"areaId\":31,\"areaName\":\"双阳街道\",\"areaType\":3,\"parentId\":4,\"status\":\"0\"},{\"areaId\":37,\"areaName\":\"南埔镇\",\"areaType\":3,\"parentId\":5,\"status\":\"0\"},{\"areaId\":44,\"areaName\":\"凤里街道\",\"areaType\":3,\"parentId\":6,\"status\":\"0\"},{\"areaId\":53,\"areaName\":\"梅岭街道\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":62,\"areaName\":\"柳城街道\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":88,\"areaName\":\"螺阳镇\",\"areaType\":3,\"parentId\":9,\"status\":\"0\"},{\"areaId\":103,\"areaName\":\"蓬莱镇\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":127,\"areaName\":\"五里街镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":149,\"areaName\":\"龙浔镇\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":186,\"areaName\":\"金沙镇\",\"areaType\":3,\"parentId\":13,\"status\":\"0\"},{\"areaId\":192,\"areaName\":\"洛阳镇\",\"areaType\":3,\"parentId\":168,\"status\":\"0\"},{\"areaId\":4,\"areaName\":\"洛江区\",\"areaType\":2,\"parentId\":1,\"status\":\"0\"},{\"areaId\":16,\"areaName\":\"鲤中街道\",\"areaType\":3,\"parentId\":2,\"status\":\"0\"},{\"areaId\":24,\"areaName\":\"泉秀街道\",\"areaType\":3,\"parentId\":3,\"status\":\"0\"},{\"areaId\":32,\"areaName\":\"罗溪镇\",\"areaType\":3,\"parentId\":4,\"status\":\"0\"},{\"areaId\":38,\"areaName\":\"界山镇\",\"areaType\":3,\"parentId\":5,\"status\":\"0\"},{\"areaId\":45,\"areaName\":\"灵秀镇\",\"areaType\":3,\"parentId\":6,\"status\":\"0\"},{\"areaId\":54,\"areaName\":\"西园街道\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":63,\"areaName\":\"美林街道\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":89,\"areaName\":\"黄塘镇\",\"areaType\":3,\"parentId\":9,\"status\":\"0\"},{\"areaId\":104,\"areaName\":\"湖头镇\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":128,\"areaName\":\"一都镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":150,\"areaName\":\"三班镇\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":187,\"areaName\":\"金湖镇\",\"areaType\":3,\"parentId\":13,\"status\":\"0\"},{\"areaId\":193,\"areaName\":\"东园镇\",\"areaType\":3,\"parentId\":168,\"status\":\"0\"},{\"areaId\":5,\"areaName\":\"泉港区\",\"areaType\":2,\"parentId\":1,\"status\":\"0\"},{\"areaId\":17,\"areaName\":\"开元街道\",\"areaType\":3,\"parentId\":2,\"status\":\"0\"},{\"areaId\":25,\"areaName\":\"清源街道\",\"areaType\":3,\"parentId\":3,\"status\":\"0\"},{\"areaId\":33,\"areaName\":\"马甲镇\",\"areaType\":3,\"parentId\":4,\"status\":\"0\"},{\"areaId\":39,\"areaName\":\"后龙镇\",\"areaType\":3,\"parentId\":5,\"status\":\"0\"},{\"areaId\":46,\"areaName\":\"宝盖镇\",\"areaType\":3,\"parentId\":6,\"status\":\"0\"},{\"areaId\":55,\"areaName\":\"罗山街道\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":64,\"areaName\":\"省新镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":90,\"areaName\":\"紫山镇\",\"areaType\":3,\"parentId\":9,\"status\":\"0\"},{\"areaId\":105,\"areaName\":\"官桥镇\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":129,\"areaName\":\"下洋镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":151,\"areaName\":\"龙门滩镇\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":188,\"areaName\":\"金城镇\",\"areaType\":3,\"parentId\":13,\"status\":\"0\"},{\"areaId\":194,\"areaName\":\"张坂镇\",\"areaType\":3,\"parentId\":168,\"status\":\"0\"},{\"areaId\":6,\"areaName\":\"石狮市\",\"areaType\":2,\"parentId\":1,\"status\":\"0\"},{\"areaId\":18,\"areaName\":\"浮桥街道\",\"areaType\":3,\"parentId\":2,\"status\":\"0\"},{\"areaId\":26,\"areaName\":\"华大街道\",\"areaType\":3,\"parentId\":3,\"status\":\"0\"},{\"areaId\":34,\"areaName\":\"河市镇\",\"areaType\":3,\"parentId\":4,\"status\":\"0\"},{\"areaId\":40,\"areaName\":\"峰尾镇\",\"areaType\":3,\"parentId\":5,\"status\":\"0\"},{\"areaId\":47,\"areaName\":\"蚶江镇\",\"areaType\":3,\"parentId\":6,\"status\":\"0\"},{\"areaId\":56,\"areaName\":\"新塘街道\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":65,\"areaName\":\"仑苍镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":106,\"areaName\":\"剑斗镇\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":130,\"areaName\":\"蓬壶镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":152,\"areaName\":\"雷峰镇\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":189,\"areaName\":\"金宁乡\",\"areaType\":3,\"parentId\":13,\"status\":\"0\"},{\"areaId\":7,\"areaName\":\"晋江市\",\"areaType\":2,\"parentId\":1,\"status\":\"0\"},{\"areaId\":19,\"areaName\":\"江南街道\",\"areaType\":3,\"parentId\":2,\"status\":\"0\"},{\"areaId\":27,\"areaName\":\"城东街道\",\"areaType\":3,\"parentId\":3,\"status\":\"0\"},{\"areaId\":35,\"areaName\":\"虹山乡\",\"areaType\":3,\"parentId\":4,\"status\":\"0\"},{\"areaId\":41,\"areaName\":\"前黄镇\",\"areaType\":3,\"parentId\":5,\"status\":\"0\"},{\"areaId\":48,\"areaName\":\"祥芝镇\",\"areaType\":3,\"parentId\":6,\"status\":\"0\"},{\"areaId\":57,\"areaName\":\"灵源街道\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":66,\"areaName\":\"东田镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":107,\"areaName\":\"城厢镇\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":131,\"areaName\":\"达埔镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":153,\"areaName\":\"南埕镇\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":190,\"areaName\":\"乌坵乡\",\"areaType\":3,\"parentId\":13,\"status\":\"0\"},{\"areaId\":8,\"areaName\":\"南安市\",\"areaType\":2,\"parentId\":1,\"status\":\"0\"},{\"areaId\":20,\"areaName\":\"金龙街道\",\"areaType\":3,\"parentId\":2,\"status\":\"0\"},{\"areaId\":28,\"areaName\":\"东海街道\",\"areaType\":3,\"parentId\":3,\"status\":\"0\"},{\"areaId\":42,\"areaName\":\"涂岭镇\",\"areaType\":3,\"parentId\":5,\"status\":\"0\"},{\"areaId\":49,\"areaName\":\"鸿山镇\",\"areaType\":3,\"parentId\":6,\"status\":\"0\"},{\"areaId\":58,\"areaName\":\"安海镇\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":67,\"areaName\":\"英都镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":108,\"areaName\":\"金谷镇\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":132,\"areaName\":\"吾峰镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":154,\"areaName\":\"水口镇\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":9,\"areaName\":\"惠安县\",\"areaType\":2,\"parentId\":1,\"status\":\"0\"},{\"areaId\":21,\"areaName\":\"常泰街道\",\"areaType\":3,\"parentId\":2,\"status\":\"0\"},{\"areaId\":29,\"areaName\":\"北峰街道\",\"areaType\":3,\"parentId\":3,\"status\":\"0\"},{\"areaId\":50,\"areaName\":\"锦尚镇\",\"areaType\":3,\"parentId\":6,\"status\":\"0\"},{\"areaId\":59,\"areaName\":\"磁灶镇\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":68,\"areaName\":\"翔云镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":94,\"areaName\":\"崇武镇\",\"areaType\":3,\"parentId\":9,\"status\":\"0\"},{\"areaId\":109,\"areaName\":\"龙门镇\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":133,\"areaName\":\"石鼓镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":155,\"areaName\":\"赤水镇\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":10,\"areaName\":\"安溪县\",\"areaType\":2,\"parentId\":1,\"status\":\"0\"},{\"areaId\":51,\"areaName\":\"永宁镇\",\"areaType\":3,\"parentId\":6,\"status\":\"0\"},{\"areaId\":60,\"areaName\":\"陈埭镇\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":69,\"areaName\":\"金淘镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":95,\"areaName\":\"山霞镇\",\"areaType\":3,\"parentId\":9,\"status\":\"0\"},{\"areaId\":110,\"areaName\":\"虎邱镇\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":134,\"areaName\":\"岵山镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":156,\"areaName\":\"上涌镇\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":11,\"areaName\":\"永春县\",\"areaType\":2,\"parentId\":1,\"status\":\"0\"},{\"areaId\":70,\"areaName\":\"诗山镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":96,\"areaName\":\"涂寨镇\",\"areaType\":3,\"parentId\":9,\"status\":\"0\"},{\"areaId\":111,\"areaName\":\"芦田镇\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":135,\"areaName\":\"东平镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":157,\"areaName\":\"葛坑镇\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":171,\"areaName\":\"东石镇\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":12,\"areaName\":\"德化县\",\"areaType\":2,\"parentId\":1,\"status\":\"0\"},{\"areaId\":71,\"areaName\":\"蓬华镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":97,\"areaName\":\"东岭镇\",\"areaType\":3,\"parentId\":9,\"status\":\"0\"},{\"areaId\":112,\"areaName\":\"感德镇\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":136,\"areaName\":\"湖洋镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":158,\"areaName\":\"盖德镇\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":172,\"areaName\":\"深沪镇\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":13,\"areaName\":\"金门县\",\"areaType\":2,\"parentId\":1,\"status\":\"0\"},{\"areaId\":72,\"areaName\":\"码头镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":98,\"areaName\":\"东桥镇\",\"areaType\":3,\"parentId\":9,\"status\":\"0\"},{\"areaId\":113,\"areaName\":\"魁斗镇\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":137,\"areaName\":\"坑仔口镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":159,\"areaName\":\"美湖镇\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":173,\"areaName\":\"金井镇\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":73,\"areaName\":\"九都镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":99,\"areaName\":\"净峰镇\",\"areaType\":3,\"parentId\":9,\"status\":\"0\"},{\"areaId\":114,\"areaName\":\"西坪镇\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":138,\"areaName\":\"玉斗镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":160,\"areaName\":\"杨梅乡\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":169,\"areaName\":\"经济技术开发区\",\"areaType\":2,\"parentId\":1,\"status\":\"0\"},{\"areaId\":174,\"areaName\":\"池店镇\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":74,\"areaName\":\"乐峰镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":100,\"areaName\":\"小岞镇\",\"areaType\":3,\"parentId\":9,\"status\":\"0\"},{\"areaId\":115,\"areaName\":\"参内镇\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":139,\"areaName\":\"锦斗镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":161,\"areaName\":\"汤头乡\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":168,\"areaName\":\"台商投资区\",\"areaType\":2,\"parentId\":1,\"status\":\"0\"},{\"areaId\":175,\"areaName\":\"内坑镇\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":75,\"areaName\":\"罗东镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":101,\"areaName\":\"辋川镇\",\"areaType\":3,\"parentId\":9,\"status\":\"0\"},{\"areaId\":116,\"areaName\":\"长卿镇\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":140,\"areaName\":\"东关镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":162,\"areaName\":\"桂阳乡\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":176,\"areaName\":\"龙湖镇\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":76,\"areaName\":\"梅山镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":117,\"areaName\":\"白濑乡\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":141,\"areaName\":\"桂洋镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":163,\"areaName\":\"国宝乡\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":177,\"areaName\":\"永和镇\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":77,\"areaName\":\"洪濑镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":118,\"areaName\":\"湖上乡\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":142,\"areaName\":\"苏坑镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":164,\"areaName\":\"大铭乡\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":178,\"areaName\":\"英林镇\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":78,\"areaName\":\"洪梅镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":119,\"areaName\":\"尚卿乡\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":143,\"areaName\":\"仙夹镇\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":165,\"areaName\":\"春美乡\",\"areaType\":3,\"parentId\":12,\"status\":\"0\"},{\"areaId\":179,\"areaName\":\"紫帽镇\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":79,\"areaName\":\"康美镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":120,\"areaName\":\"大坪乡\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":144,\"areaName\":\"横口乡\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":180,\"areaName\":\"西滨镇\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":80,\"areaName\":\"丰州镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":121,\"areaName\":\"龙涓乡\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":145,\"areaName\":\"呈祥乡\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":181,\"areaName\":\"安平开发区\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":81,\"areaName\":\"霞美镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":122,\"areaName\":\"蓝田乡\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":146,\"areaName\":\"介福乡\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":182,\"areaName\":\"晋江市经济开发区\",\"areaType\":3,\"parentId\":7,\"status\":\"0\"},{\"areaId\":82,\"areaName\":\"官桥镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":123,\"areaName\":\"祥华乡\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":147,\"areaName\":\"外山乡\",\"areaType\":3,\"parentId\":11,\"status\":\"0\"},{\"areaId\":83,\"areaName\":\"水头镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":124,\"areaName\":\"桃舟乡\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":84,\"areaName\":\"石井镇\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":125,\"areaName\":\"福田乡\",\"areaType\":3,\"parentId\":10,\"status\":\"0\"},{\"areaId\":85,\"areaName\":\"眉山乡\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":86,\"areaName\":\"向阳乡\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"},{\"areaId\":183,\"areaName\":\"雪峰管委会\",\"areaType\":3,\"parentId\":8,\"status\":\"0\"}]";

    /**
     * 小区
     */
    // HashBiMap<Long, Object> areaMap = HashBiMap.create();
    private static HashBiMap<Long, Object> areaMap;

    /**
     * 街道
     * 
     * 注：这个类型坑爹在对类型强校验，如果rowKey指定了Long类型，用int,object都会取不到值。坑
     */
    // Table<Long, Object, Object> table = HashBasedTable.create();
    private static Table<Long, Object, Object> table;

    /**
     * 全地区ID对应MAP
     */
    private static HashMap<Long, String> allAreaIdMap;

    static {
        areaMap = HashBiMap.create();
        strToAreaMap();
        table = HashBasedTable.create();
        strToTable();
        allAreaIdMap = new HashMap<Long, String>();
        strToAllAreaMap();
    }

    // {"0":"区县（必填）","1":"街道(镇/乡)（必填）"}
    private Integer areaIndex = 0;

    private Integer streetIndex = 1;

    @Override
    public Class<Object> supportJavaTypeKey() {
        return Object.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return null;
    }

    /**
     * 转换出去要与元素同类型，不然会报类型转换失败。
     */
    @Override
    public Long convertToJavaData(ReadConverterContext<?> context) {
        Long result = 0L;
        try {
            // {0:{"columnIndex":0,"dataFormatData":{"format":"General","index":0},"numberValue":3.0,"originalNumberValue":3.0,"rowIndex":3,"type":2},1:{"columnIndex":1,"rowIndex":3,"stringValue":"丰泽区小区3","type":0},2:{"columnIndex":2,"rowIndex":3,"stringValue":"丰泽区","type":0},3:{"columnIndex":3,"rowIndex":3,"stringValue":"丰泽街道","type":0}}
            Integer index = context.getReadCellData().getColumnIndex();
            Map<Integer, Cell> cellMap = context.getAnalysisContext().readRowHolder().getCellMap();
            ReadCellData<?> areaCellData = (ReadCellData<?>)cellMap.get(areaIndex);
            Object areaValue = areaCellData.getStringValue();
            // 转换地区
            // strToAreaMap();
            Long areaId = areaMap.inverse().get(areaValue);
            if (index == areaIndex) {
                // 获取区县

                // 翻转获取type=2的ID
                result = areaId;
            }
            if (index == streetIndex) {
                strToTable();
                // 获取街道
                ReadCellData<?> streetCellData = (ReadCellData<?>)cellMap.get(streetIndex);
                Object streetValue = streetCellData.getStringValue();
                // rowKey要是Long类型
                Object streetId = table.get(areaId, streetValue);
                if (StringUtils.isNotNull(streetId)) {
                    result = Long.valueOf(streetId.toString());
                }
            }
        } catch (Exception e) {
            log.error("导入地区转换对象异常", e);
            // e.printStackTrace();
        }
        return result;
    }

    @Override
    public WriteCellData<String> convertToExcelData(Object object, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        if (ObjectUtil.isNull(object)) {
            return new WriteCellData<>("");
        }
        String value = Convert.toStr(object);
        String label = ConverConfig.EMPTY;
        if (StringUtils.isNotEmpty(value)) {
            // strToAllAreaMap();
            label = allAreaIdMap.get(Long.valueOf(value));
        }
        return new WriteCellData<>(label);
    }

    private static void strToAreaMap() {
        try {
            if (areaMap.isEmpty()) {
                JSONArray jsonArray = JSON.parseArray(AREA);
                for (int i = 0; i < jsonArray.size(); i++) {
                    JSONObject json = jsonArray.getJSONObject(i);
                    Integer areaType = json.getInteger("areaType");
                    // 区县类型单独转换
                    if (areaType == 2) {
                        Long areaId = json.getLong("areaId");
                        String areaName = json.getString("areaName");
                        areaMap.put(areaId, areaName);
                    }
                }
            }
        } catch (Exception e) {
            log.error("地区字符串转换HashBiMap异常", e);
        }
    }

    private static void strToTable() {
        try {
            if (table.isEmpty()) {
                JSONArray jsonArray = JSON.parseArray(AREA);
                for (int i = 0; i < jsonArray.size(); i++) {
                    JSONObject json = jsonArray.getJSONObject(i);
                    // Long areaId = json.getLong("areaId");
                    Object areaId = json.get("areaId");
                    Long parentId = json.getLong("parentId");
                    // Object parentId = json.get("parentId");
                    // String areaName = json.getString("areaName");
                    Object areaName = json.get("areaName");
                    if (Long.valueOf(parentId.toString()) > 0) {
                        // table.put(areaId, parentId, areaName);
                        table.put(parentId, areaId, areaName);
                        table.put(parentId, areaName, areaId);
                    }
                }
            }
        } catch (Exception e) {
            log.error("地区字符串转换Table异常", e);
        }
    }

    private static void strToAllAreaMap() {
        try {
            if (allAreaIdMap.isEmpty()) {
                JSONArray jsonArray = JSON.parseArray(AREA);
                for (int i = 0; i < jsonArray.size(); i++) {
                    JSONObject json = jsonArray.getJSONObject(i);
                    // 区县类型单独转换
                    Long areaId = json.getLong("areaId");
                    String areaName = json.getString("areaName");
                    allAreaIdMap.put(areaId, areaName);
                }
            }
        } catch (Exception e) {
            log.error("地区字符串转换Map异常", e);
        }
    }
}
